<include file="../header"/>
<div class="wrapper">
    <div class="main">
        <div class="header text-center font-16">
            智能报修
            <div class="iconfont icon-zuo go_back"></div>
        </div>
        <if condition="!$data">
            <if condition="$status eq 1 OR !$status">
                <div class="hint">
                    <img src="/assets/repaireast/images/hint.png" alt="">

                    <p class="text-center gray2">暂无可指派订单</p>
                </div>
            </if>
            <if condition="$status eq 2">
                <div class="hint">
                    <img src="/assets/repaireast/images/hint.png" alt="">

                    <p class="text-center gray2">暂无已指派订单</p>
                </div>
            </if>
        </if>
        <if condition="!$patrolLog">
            <if condition="$status eq 3">
                <div class="hint">
                    <img src="/assets/repaireast/images/hint.png" alt="">

                    <p class="text-center gray2">暂无巡检记录</p>
                </div>
            </if>

        </if>
        <if condition="$data OR $patrolLog">
            <div class="history-list">
                <if condition="$status neq 3">
                    <volist name="data" id="vo">
                        <div class="list order_list" data-id="{BEESCRM:$vo.order_id}"
                             data-status="{BEESCRM:$vo.status}">
                            <div>
                                <if condition="$vo['type'] eq 3">
                                    <span class="everyday green-bg">快捷</span>
                                    <elseif condition="$vo['type'] eq 2"/>
                                    <span class="everyday red-bg">公共</span>
                                    <else/>
                                    <span class="everyday">日常</span>
                                </if>
                                <span>{BEESCRM:$vo.contents}</span>
                            </div>
                            <div>
                            <span class="gray font-12">
                                {BEESCRM:$vo.create_time|date="Y-m-d",###}
                            </span>
                            <span class="pull-right orange">
                                <if condition="$vo['status'] eq 0">
                                    已取消
                                    <elseif condition="$vo['status'] eq 1"/>
                                    已下单
                                    <elseif condition="$vo['status'] eq 2"/>
                                    已指派
                                    <elseif condition="$vo['status'] eq 3"/>
                                    已接单
                                    <elseif condition="$vo['status'] eq 4"/>
                                    已挂单
                                    <elseif condition="$vo['status'] eq 5"/>
                                    已维修
                                    <elseif condition="$vo['status'] eq 6"/>
                                    已评价
                                </if>
                            </span>
                            </div>
                        </div>
                    </volist>
                </if>
                <if condition="$status eq 3">
                    <div class="history-list" id="patrol_list">
                        <volist name="patrolLog" id="vo">
                            <div class="list padding-12-0 patrol_list" data-id="{BEESCRM:$vo.log_id}">
                                <span>{BEESCRM:$vo.create_time|date="Y-m-d",###}</span>
                                <span>{BEESCRM:$vo.patrol_object}</span>
                                <!--<span class="pull-right font-16">{BEESCRM:$vo.content}</span>-->
                            </div>
                        </volist>
                    </div>
                </if>

            </div>
        </if>
    </div>
    <div class="flex add text-center Bottom-btn">
        <a href="/Repaireast/Repaireast/index/status/1" class="bottom-btn">
            <span class="iconfont icon-baoxiu"></span>

            <p class="">未指派</p>
        </a>
        <if condition="$patrolRepair eq 0">
            <a href="#" id="patrol_repair" class="bottom-btn">
                <span class="iconfont icon-baoxiu"></span>

                <p class="">巡检</p>
            </a>
            <a href="/Repaireast/Repaireast/index/status/3" class="bottom-btn">
                <span class="iconfont icon-wodebaoxiudan"></span>

                <p class="" id="patrol">巡检记录</p>
            </a>
        </if>
        <a href="/Repaireast/Repaireast/index/status/2" class="bottom-btn">
            <span class="iconfont icon-wodebaoxiudan"></span>

            <p class="">已指派</p>
        </a>
    </div>
</div>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
    $('.order_list').click(function () {
        var id = $(this).data('id');
        var status = $(this).data('status');
        var role = "{BEESCRM:$role}";
        //if (role == 'manager' && status == 1){
        var url = '/Repaireast/RepaireastManager/orderDetail/order_id/' + id;
        //}else {
        //    var url = '/Repaireast/Repaireast/orderDetail/order_id/' + id;
        //}
        window.location.href = url;
    });

    wx.config({
        debug: false,
        appId: "{BEESCRM:$appid}",
        timestamp: "{BEESCRM:$timestamp}",
        nonceStr: "{BEESCRM:$noncestr}",
        signature: "{BEESCRM:$signature}",
        jsApiList: ['checkJsApi', 'scanQRCode'],
    });
    wx.ready(function () {
        //调起扫码
        $('#patrol_repair').click(function () {
            wx.scanQRCode({
                needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                scanType: ["qrCode"], // 可以指定扫二维码还是一维码，默认二者都有
                success: function (res) {
                    //var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                    var id = res.resultStr;
                    if (id.indexOf("patrol_id") > 0) {
                        var url = '/Repaireast/RepaireastWorker/patrolRepair/patrol_id/' + id;
                        window.location.href = url;
                    } else {
                        fm.alert("请扫描正确的二维码！");
                    }
                }
            });
        });
    })


    $('.patrol_list').click(function () {
        var id = $(this).data('id');
        var url = '/Repaireast/RepaireastWorker/patrolInfo/log_id/' + id;
        window.location.href = url;
    });
</script>
<include file="../footer"/>